package com.ruoyi.bath.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bath.domain.manager;
import com.ruoyi.bath.service.IManagerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 经理信息Controller
 * 
 * @author ruoyi
 * @date 2021-08-05
 */
@RestController
@RequestMapping("/bath/manager")
public class ManagerController extends BaseController
{
    @Autowired
    private IManagerService managerService;

    /**
     * 查询经理信息列表
     */
    @PreAuthorize("@ss.hasPermi('bath:manager:list')")
    @GetMapping("/list")
    public TableDataInfo list(manager manager)
    {
        startPage();
        List<com.ruoyi.bath.domain.manager> list = managerService.selectManagerList(manager);
        return getDataTable(list);
    }

    /**
     * 导出经理信息列表
     */
    @PreAuthorize("@ss.hasPermi('bath:manager:export')")
    @Log(title = "经理信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(manager manager)
    {
        List<com.ruoyi.bath.domain.manager> list = managerService.selectManagerList(manager);
        ExcelUtil<com.ruoyi.bath.domain.manager> util = new ExcelUtil<com.ruoyi.bath.domain.manager>(com.ruoyi.bath.domain.manager.class);
        return util.exportExcel(list, "经理信息数据");
    }

    /**
     * 获取经理信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('bath:manager:query')")
    @GetMapping(value = "/{managerId}")
    public AjaxResult getInfo(@PathVariable("managerId") Integer managerId)
    {
        return AjaxResult.success(managerService.selectManagerBymanagerId(managerId));
    }

    /**
     * 新增经理信息
     */
    @PreAuthorize("@ss.hasPermi('bath:manager:add')")
    @Log(title = "经理信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody manager manager)
    {
        return toAjax(managerService.insertManager(manager));
    }

    /**
     * 修改经理信息
     */
    @PreAuthorize("@ss.hasPermi('bath:manager:edit')")
    @Log(title = "经理信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody manager manager)
    {
        return toAjax(managerService.updateManager(manager));
    }

    /**
     * 删除经理信息
     */
    @PreAuthorize("@ss.hasPermi('bath:manager:remove')")
    @Log(title = "经理信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{managerIds}")
    public AjaxResult remove(@PathVariable Integer[] managerIds)
    {
        return toAjax(managerService.deleteManagerBymanagerIds(managerIds));
    }
}
